<template>
	<view class="content">
		<u-tabbar :value="currentTab" :fixed="true" :placeholder="true" activeColor="#259C77" :border="false" inactiveColor="#fff">
			<u-tabbar-item @click="clickTab" :badge="sessionCount+newFriendCount" :badgeStyle="{fontSize:'20rpx'}">
				<div class="tabbar-icon" slot="active-icon">
					<u-icon name="/static/tab/msg-on.png" size="48rpx" :label="t('index.index.title')" labelPos="bottom" labelSize="24rpx" space="2px"></u-icon>
				</div>
				<u-icon slot="inactive-icon" name="/static/tab/msg.png" size="48rpx" color="#fff" :label="t('index.index.title')" labelPos="bottom" labelSize="24rpx" space="2px" label-color="#fff"></u-icon>
			</u-tabbar-item>
			<u-tabbar-item @click="clickTab" :badgeStyle="{fontSize:'20rpx'}">
				<div class="tabbar-icon" slot="active-icon" >
					<u-icon name="/static/tab/video-on.png" size="48rpx" :label="t('astral.index.title')" labelPos="bottom" labelSize="24rpx" space="2px"></u-icon>
				</div>
				<u-icon slot="inactive-icon" name="/static/tab/video.png" size="48rpx" color="#fff" :label="t('astral.index.title')" labelPos="bottom" labelSize="24rpx" space="2px" label-color="#fff"></u-icon>
			</u-tabbar-item>
			<u-tabbar-item @click="clickTab" :badgeStyle="{fontSize:'20rpx'}">
				<div class="tabbar-icon" slot="active-icon" >
					<u-icon name="/static/tab/find-on.png" size="48rpx" :label="t('chum.index.title')" labelPos="bottom" labelSize="24rpx" space="2px"></u-icon>
				</div>
				<u-icon slot="inactive-icon" name="/static/tab/find.png" size="48rpx" color="#fff" :label="t('chum.index.title')" labelPos="bottom" labelSize="24rpx" space="2px" label-color="#fff"></u-icon>
			</u-tabbar-item>
			<u-tabbar-item @click="clickTab" :badgeStyle="{fontSize:'20rpx'}">
				<div class="tabbar-icon" slot="active-icon">
					<u-icon name="/static/tab/my-on.png" size="48rpx" :label="t('my.index.title')" labelPos="bottom" labelSize="24rpx" space="2px"></u-icon>
				</div>
				<u-icon slot="inactive-icon" name="/static/tab/my.png" size="48rpx" color="#fff" :label="t('my.index.title')" labelPos="bottom" labelSize="24rpx" space="2px" label-color="#fff"></u-icon>
			</u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	// nvue 多语言
	import { initVueI18n } from '@dcloudio/uni-i18n';
	import messages from '@/locale/index.js';
	const { t } = initVueI18n(messages)
	export default {
		name: 'tabbar',
		props:['currentTab'],
		computed: {
			...mapState({
				sessionCount: state => state.tabbarbadge.sessionCount,
				newFriendCount: state => state.tabbarbadge.newFriendCount,
				isConnected: state => state.isConnected,
				reconnectCount: state => state.reconnectCount,
			})
		},
		data() {
			return {
				t,
				jbstyle:{ 
					'background-image': 'linear-gradient(90deg, #FFFFFF 0%, #E5BD84 100%)',
					'-webkit-background-clip': 'text',
					'-webkit-text-fill-color': 'transparent',
				},
				switchTab: [
					"/pages/index/index",
					"/pages/playlet/playlet",
					"/pages/chum/index",
					"/pages/my/index",
				]
			}
		},
		methods: {
			clickTab(e) {
				if(this.switchTab[e] == '/pages/index/index'){
					this.$emit('click',e)
				}
				uni.$Router.pushTab(this.switchTab[e])
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	// .tabbar-icon {
	// 	width: 86rpx;
	// 	height: 86rpx;
	// 	background: #259C77;
	// 	border-radius: 50%;
	// 	display: flex;
	// 	align-items: center;
	// 	justify-content: center;
	// }
</style>
